package com.spring.until;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Hex;

public class PassWordsUtil {
    private static String key = "hzx&hjh" ;
    public static String toMd5(String pwd) {
        MessageDigest messageDigest = null;
        try {
            messageDigest = MessageDigest.getInstance("MD5");
            byte[] bytes = messageDigest.digest(pwd.getBytes());
            String str =  Hex.encodeHexString(bytes)+key ;
            bytes = messageDigest.digest(str.getBytes()) ;
            return Hex.encodeHexString(bytes) ;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null ;
        }
    }
}
